package com.itheima.reggie.common;

import com.itheima.reggie.entity.LoggingEvent;

/**
 * @author : xyiaao
 * @createDate : 2022/2/6 8:42
 */
public class BaseContext {

    private static ThreadLocal<Long> threadLocalId = new ThreadLocal<>();

    private static ThreadLocal<LoggingEvent> threadLocalLoggingEvent = new ThreadLocal<>();

    /**
     * 设置id值
     *
     * @param id
     */
    public static void setCurrentId(Long id) {
        threadLocalId.set(id);
    }


    /**
     * 获取id值
     *
     * @return
     */
    public static Long getCurrentId() {
        return threadLocalId.get();
    }


    public static void setLoggingEvent(LoggingEvent loggingEvent) {

        threadLocalLoggingEvent.set(loggingEvent);
    }

    public static LoggingEvent getLoggingEvent() {
        return threadLocalLoggingEvent.get();
    }

}
